package com.cn.wxwinnie.web.socket;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author 潇湘暮雨 E-mail:wxwinnie@hotmail.com
 * 
 * @version 创建时间：2014年3月25日 上午11:39:37
 * 
 */
public class Server {
	private ServerSocket ss;
	private Socket socket;
	private BufferedReader in;
	private PrintWriter out;

	public Server() throws IOException {
		try {
			ss = new ServerSocket(10000);

			while (true) {
				socket = ss.accept();
				in = new BufferedReader(new InputStreamReader(
						socket.getInputStream()));
				out = new PrintWriter(socket.getOutputStream(), true);

				String line = in.readLine();
				out.println("you input is :" + line);
				out.close();
				in.close();
				socket.close();
			}
			//ss.close();
			
		} catch (IOException e) {
		}finally{
			if(ss!= null)
				ss.close();
		}
	}

	public static void main(String[] args) throws IOException {
		new Server();
	}
}